/*
 * @(#)Attribute.java        0.1 09/04/29
 * @version 	0.1 29 Apr 2009
 * @author 	Tran Dai Hiep
 * 
 * The hien mot attribute trong ClassFrame, thua ke tu lop truu tuong AttributeMethod
 */


package GUI;

import javax.swing.*;

public class Attribute extends AttributeMethod {
	public Attribute(String text,int type, ClassFrame classFrame) {
		super(text, type, classFrame);
	}
	
	public Attribute(Attribute a, ClassFrame classFrame) {
		super(a, classFrame);
	}
	
	/*
	 * Luu attribute vao class 
	 * @see GUI.AttributeMethod#save()
	 */
	public void save() {
		Data.Class c = classFrame.getClassData();
		c.addAttribute(nameTextField.getText());
	}
	
	/*
	 * Su kien click button delete
	 * @see GUI.AttributeMethod#deleteButton_Clicked()
	 */
	public void deleteButton_Clicked() {
		Data.Class c = classFrame.getClassData();
		if (nameTextField.getName() != null) {
			c.removeAttribute(nameTextField.getName());
		}
		JPanel tmp = (JPanel)me.getParent();
		tmp.remove(me);
		tmp.updateUI();
		MainFrame.isSaved = false;
		MainFrame.isLogged = false;
		//log.push(new ClassWithShape(c, classFrame));
	}
}
